#include "../bsp/beep/bsp_beep.h"
#include "../bsp/clk/bsp_clk.h"
#include "../bsp/delay/bsp_delay.h"
#include "../bsp/int/bsp_int.h"
#include "../bsp/led/bsp_led.h"
#include "../bsp/rtc/bsp_hp_rtc.h"
#include "../bsp/rtc/bsp_hp_rtc_alarm.h"
#include "../bsp/rtc/bsp_rtc.h"
#include "../stdio/include/stdio.h"
#include <string.h>

/*
 * @description	: main函数
 * @param 		: 无
 * @return 		: 无
 */
int main(void) {

  int_init();      /* 初始化中断(一定要最先调用！) */
  imx6u_clkinit(); /* 初始化系统时钟 			*/
  clk_enable();    /* 使能所有的时钟 			*/
  led_init();      /* 初始化led 			*/
  beep_init();

  rtc_init();
  RTC_HP_Init();
  rtc_datetime datatime = {1970, 1, 1, 0, 0, 5};

  RTC_HP_Alarm_Init();
  RTC_HP_Alarm_Setdatetime(&datatime);
  GIC_EnableIRQ(SNVS_Consolidated_IRQn);
  system_register_irqhandler(SNVS_Consolidated_IRQn, alarm_irq, NULL);
  RTC_HP_Alarm_Enable();
  
  char s[256];
  memset(s,strlen(s),0);
  
  while (1) {
    RTC_HP_Getdatetime(&datatime);
    printf("HP %d %d %d %d %d %d \r\n", datatime.year, datatime.month,
           datatime.day, datatime.hour, datatime.minute, datatime.second);
    rtc_getdatetime(&datatime);
    printf("LP %d %d %d %d %d %d \r\n", datatime.year, datatime.month,
           datatime.day, datatime.hour, datatime.minute, datatime.second);
    //   led_switch(LED0, 1);
    delay_ms(500);
    //   led_switch(LED0, 0);
    //    delay_ms(500);
  }

  return 0;
}
